package com.xms.sdk.service;

import com.xms.core.exception.XmsException;
import com.xms.sdk.core.DynamicData;
import com.xms.sdk.core.query.*;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * IAggregateService
 * </p>
 *
 * @author migo
 * @since 2021/9/7
 */
public interface IAggregateService {
    List<DynamicData> execute(AggregateExpression agg) throws SQLException, XmsException;

    List<DynamicData> execute(QueryExpression query, Map<String, AggregateType> attributeAggs, List<String> groupFields) throws SQLException, XmsException;

    List<DynamicData> groupingTop(int top, String groupField, QueryExpression query, OrderExpression order) throws XmsException, SQLException;

    long count(String entityName, FilterExpression filter) throws SQLException, XmsException;

    double sum(String entityName, FilterExpression filter) throws SQLException, XmsException;

    double avg(String entityName, FilterExpression filter) throws SQLException, XmsException;

    double max(String entityName, FilterExpression filter) throws SQLException, XmsException;

    double min(String entityName, FilterExpression filter) throws SQLException, XmsException;

    Object getValue(String entityName, FilterExpression filter, AggregateType aggregateType) throws SQLException, XmsException;


}
